﻿#region zh-CHS 2010 - 2010 DemoSoft 团队 | en 2010-2010 DemoSoft Team

//     NOTES
// ---------------
//
// This file is a part of the MMOCE(Massively Multiplayer Online Client Engine) for .NET.
//
//                              2010-2010 DemoSoft Team
//
//
// First Version : by H.Q.Cai - mailto:caihuanqing@hotmail.com

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published
 *   by the Free Software Foundation; either version 2.1 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

#region zh-CHS 包含名字空间 | en Include namespace
using System;
using Demo.Silverlight.Core.Common;
using Demo.Silverlight.Core.ClientEngine.Entity.Creature;
using Demo.Silverlight.Core.Common.Template;
#endregion


namespace Demo.Silverlight.Core.Entity.Creature
{
    /// <summary>
    /// Base class representing players, npcs, and creatures.
    /// </summary>
    public abstract class CreatureBase : Demo.Silverlight.Core.Entity.Unit.Unit, IComparable, IComparable<CreatureBase>
    {
        #region zh-CHS 构造和初始化和清理 | en Constructors and Initializers and Dispose
        /// <summary>
        /// 默认构造函数
        /// </summary>
        public CreatureBase()
        {
            DefaultCreatureInit();
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="serial">唯一序号</param>
        public CreatureBase( Serial serial )
            : base( serial )
        {
            DefaultCreatureInit();
        }

        #region zh-CHS 人物的初始化 | en
        /// <summary>
        /// 缺省的初始化人物
        /// </summary>
        protected virtual void DefaultCreatureInit()
        {
        }
        #endregion

        #endregion

        #region zh-CHS 共有属性 | en Public Properties

        #region zh-CHS Name属性 | en Public Properties

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 人物的名字
        /// </summary>
        private string m_Name = string.Empty;
        #endregion
        /// <summary>
        /// 人物的名字
        /// </summary>
        public string Name
        {
            get { return m_Name; }
            set { m_Name = value; }
        }

        #endregion
 
        #region zh-CHS CreationTime 属性 | en Public Properties

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 人物实例产生的时间
        /// </summary>
        private DateTime m_CreationTime = DateTime.Now;
        #endregion
        /// <summary>
        /// 实例人物时产生的时间
        /// </summary>
        public DateTime CreationTime
        {
            get { return m_CreationTime; }
        }

        #endregion

        #endregion

        #region zh-CHS 接口实现 | en Interface Implementation
        /// <summary>
        /// 
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public int CompareTo( CreatureBase other )
        {
            return CompareTo( other as WorldEntity );
        }
        #endregion

        #region zh-CHS 方法覆盖 | en Override Methods
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return m_Name;
        }
        #endregion
    }

    /// <summary>
    /// 
    /// </summary>
    public abstract class CreatureBase<CreatureTemplateT> : CreatureBase, ITemplateSerial
        where CreatureTemplateT : CreatureTemplateBase
    {
        #region zh-CHS CreatureTemplate属性 | en Public Properties

        /// <summary>
        /// 模板的Id
        /// </summary>
        /// <returns></returns>
        public Serial TemplateSerial
        {
            get
            {
                CreatureTemplateT creatureTemplate = m_CreatureTemplate;
                if ( creatureTemplate == null )
                    return Serial.MinusOne;
                else
                    return creatureTemplate.Serial;
            }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 人物的帐号等级
        /// </summary>
        private CreatureTemplateT m_CreatureTemplate = default( CreatureTemplateT );
        #endregion
        /// <summary>
        /// 人物的帐号等级
        /// </summary>
        public CreatureTemplateT CreatureTemplate
        {
            get { return m_CreatureTemplate; }
            set { m_CreatureTemplate = value; }
        }

        #endregion
    }
}
#endregion